package com.hzhc.controller.wxapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzhc.common.BaseController;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.TrainPlanService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.vo.TrainPlanVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author dongcy
 * @date 2024/8/13 18:46
 * @description WxApiTrainPlanController
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/app")
public class WxApiTrainPlanController extends BaseController {

    private final TrainPlanService planService;

    //小程序 list
    @RequestMapping("/getWxTrainPlanList")
    public ResultUtil<List<TrainPlanVo>> getWxTrainPlanList(HttpServletRequest request, @RequestBody TrainPlanVo vo){
        Page<TrainPlanVo> page = new Page<>(vo.getPageIndex(),vo.getPageSize());
        List<TrainPlanVo> list = planService.getWxTrainPlanList(page,vo);
        return ResultUtil.build(list,page.getTotal(),page.getPages(), ResultUtilCodeEnum.SUCCESS);
    }

    //完工按钮
    @PostMapping("/updateFinishStatus")
    public ResultUtil<T> updateFinishStatus(HttpServletRequest request, @RequestBody TrainPlanVo vo){
        return planService.updateFinishStatus(vo);
    }


}
